package hk.m4s.lr.repair.test.views;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.model.CouponModel;
import hk.m4s.lr.repair.test.ui.adapter.CouponListAdapter;
import hk.m4s.lr.repair.test.utils.ToastUtil;

public class BottomtoTopDialog extends Dialog {

    private Context context;
    private View.OnClickListener onClickListener;

    private ListView couponListView;
    private TextView btn_cancel;
    private ImageView closeBtn;
    private List<CouponModel> couponList;
    private CouponListAdapter couponListAdapter;
    public BottomtoTopDialog(Context context,
                             View.OnClickListener onClickListener) {
        super(context, R.style.report_dialog);
        this.context = context;
        this.onClickListener = onClickListener;
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.bottomtotopdialog);
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE |
                WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

        couponListView = (ListView) findViewById(R.id.couponList);
        closeBtn = (ImageView) findViewById(R.id.close);
        btn_cancel = (TextView) findViewById(R.id.btn_cancel);
        closeBtn.setOnClickListener(onClickListener);
        btn_cancel.setOnClickListener(onClickListener);
        couponList=new ArrayList<>();
        CouponModel model=new CouponModel();
        model.setCouponId("1001");
        model.setCouponName("店铺优惠券");
        model.setCouponPrice("100");
        model.setCouponRule("满1000元使用");
        model.setStartTime("2017-09-01");
        model.setEndTime("2017-10-11");
        CouponModel models=new CouponModel();
        models.setCouponId("1001");
        models.setCouponName("店铺优惠券");
        models.setCouponPrice("150");
        models.setCouponRule("满1500元使用");
        models.setStartTime("2017-09-01");
        models.setEndTime("2017-10-11");
        couponList.add(model);
        couponList.add(models);
        couponListAdapter=new CouponListAdapter(context,couponList);
        couponListView.setAdapter(couponListAdapter);
        couponListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            }
        });
    }

}
